# -*- coding: utf-8 -*-
import xadmin
from message_model.models import MessageTemplet,MessageTempletNoButton
from dysms_python.demo_sms_send import send_sms
import uuid
class MessageTempletManageAdmin(object):
    list_display = ('template_name','template_type','sign_name','template','template_code','template_illustrate','change_status','change_button','desc')
    list_filter = ['sign_name', 'template','template_code','create_time']
    list_per_page = 20
    exclude = ['id']
    model_icon = 'fa fa-file-text'
    readonly_fields = ['change_status','status']





class MessageTempletNoButtonAdmin(object):
    list_display = ('template_name','template_type','sign_name','template','template_code','template_illustrate','change_status','desc')
    list_filter = ['sign_name', 'template','template_code','create_time']
    list_per_page = 20
    exclude = ['id']
    readonly_fields = ['template_code','status','change_status','desc' ]
    model_icon = 'fa fa-file-text'

    def save_models(self):
        obj = self.new_obj
        obj.status = 0
        obj.save()
        __business_id = uuid.uuid1()
        send_sms(__business_id, '17765254279', '广东原昇', 'SMS_143865985', None)



xadmin.site.register(MessageTemplet,MessageTempletManageAdmin)
xadmin.site.register(MessageTempletNoButton,MessageTempletNoButtonAdmin)
